package com.wuxianedu.servive;

import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

/**
 * Created by TED on 2016/9/21.
 */
public class MIxActivity extends AppCompatActivity implements View.OnClickListener {

    private Intent intent;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.acticity_mix);
        intent = new Intent(this,MixStartService.class);
        init();
    }


    private void init() {
        findViewById(R.id.start_mix).setOnClickListener(this);
        findViewById(R.id.stop_mix).setOnClickListener(this);
        findViewById(R.id.bind_mix).setOnClickListener(this);
        findViewById(R.id.unbind_mix).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.start_mix:
                startService(intent);
                break;
            case R.id.stop_mix:
                stopService(intent);
                break;
            case R.id.bind_mix:
                bindService(intent, conn, BIND_AUTO_CREATE);
                break;
            case R.id.unbind_mix:
                unbindService(conn);
                break;
        }
    }

    private ServiceConnection conn = new ServiceConnection() {
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {

        }

        @Override
        public void onServiceDisconnected(ComponentName name) {

        }
    };
}
